package com.parkcar;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import HttpUtils.HttpQniuRequest;
import util.BaseActivity;
import util.BaseUtil;

/**
 * Created by Administrator on 2016/3/8.
 */
public class LoadingActivity extends BaseActivity{
    private HttpQniuRequest infoRequest;
    private boolean isFinish;
    @Override
    protected void setUpui(Bundle arg0) {
        setContentView(R.layout.activity_loading);
        setTitleGone(View.GONE);
        getToken();
        mHandle.sendEmptyMessageDelayed(0,6000);
    }

    @Override
    protected void updateUI(boolean isLogin) {

    }
    private void getToken(){
        infoRequest = new HttpQniuRequest(this);
        infoRequest.setmIHttpClinetListener(this);
        infoRequest.doRequest();
    }

    @Override
    public void httpSuccessListener(Bundle successMsg) {
        super.httpSuccessListener(successMsg);
        if(mBaseResult!=null&&mBaseResult.getStatus().getRetCode()==0){
            String token = mBaseResult.getData();
            BaseUtil.setQNToken(this,token);
        }
        mHandle.sendEmptyMessageDelayed(0,2000);
    }
    private Handler mHandle = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(!isFinish){
                isFinish=true;
            KipActivity(MainActivity.class,null);
            }
        }
    };
}
